﻿# Called every Jan 1st
# Root does not exist
yearly_global_pulse = {
	effect = {
		# Historical character spawner
		if = {
			limit = {
				NOT = {
					has_game_rule = no_historical_characters
				}
			}
			spawn_historical_characters_effect = yes
		}
		# Visigothic culture split
		## Deprecated; to reenable, remove always = no line & decomment the trigger_event section.
		if = {
			limit = {
				always = no
				current_date <= 920.1.1 # No need to check this in later starts
				NOT = { has_global_variable = visigothic_culture_split }
				current_date >= 850.1.1
			}
			random = {
				chance = 0 # No chance the first year of play if starting in 867
				modifier = {
					add = 10
					current_date >= 868.1.1
				}
				modifier = {
					add = 10 # 20% chance
					current_date >= 875.1.1
				}
				modifier = {
					add = 10 # 30% chance
					current_date >= 890.1.1
				}
				set_global_variable = {
					name = visigothic_culture_split
					value = yes
				}
				#trigger_event = {
					#id = global_culture.0001
					#days = { 60 300 }
				#}
			}
		}
		# Norse culture split.
		if = {
			limit = {
				current_date < 990.1.1
				NOT = { has_global_variable = norse_culture_split }
				current_date >= 950.1.1
			}
			random = {
				chance = 10
				modifier = {
					add = 20 # 30% chance
					current_date >= 960.1.1
				}
				modifier = {
					add = 30 # 60% chance
					current_date >= 970.1.1
				}
				modifier = {
					add = 40 # 100% chance
					current_date >= 980.1.1
				}
				set_global_variable = {
					name = norse_culture_split
					value = yes
				}
				trigger_event = {
					id = global_culture.0011
					days = { 60 300 }
				}
			}
		}
		# Anglo-Saxon -> Scottish Culture Shift
		if = {
			limit = {
				current_date <= 1066.1.1 # No need to check this in later starts
				NOT = { has_global_variable = scottish_culture_creation }
				current_date >= 867.1.1
			}
			random = {
				chance = 0 # No chance the first year of play if starting in 867
				modifier = {
					add = 2 # 2% chance per year
					current_date >= 900.1.1
				}
				modifier = {
					add = 8 # 10% chance per year
					current_date >= 950.1.1
				}
				modifier = {
					add = 15 # 25% chance per year
					current_date >= 1000.1.1
				}
				set_global_variable = {
					name = scottish_culture_creation
					value = yes
				}
				trigger_event = {
					id = global_culture.0031
					days = { 60 300 }
				}
			}
		}
		# Mongol Invasion
		if = { limit = { has_game_rule = never_mongol_invasion } }
		else_if = {
			limit = {
				has_game_rule = random_mongol_invasion
				NOT = { has_global_variable = mongols_have_appeared }
				#Greatest of khans hasn't come along
				NOT = { has_global_variable = greatest_of_khans_title }
				#Someone's not currently trying to be greatest of khans
				NOT = { has_global_variable = mpo_gok_war_ongoing }
				#Temujin dying prevents Mongol invasion for at least 50 years
				NOT = {
					has_global_variable = temujin_failed
				}
			}
			random = {
				chance = temujin_appearance_base_chance
				modifier = {
					factor = 0.25
					current_date < 1180.1.1
				}
				modifier = {
					add = 3
					current_date > 1200.1.1
				}
				modifier = {
					add = 5
					current_date > 1220.1.1
				}
				modifier = {
					add = 5
					current_date > 1235.1.1
				}
				set_global_variable = {
					name = mongols_have_appeared
					value = yes
				}
				debug_log = "Attempting to spawn mongol invasion within 240 days"
				trigger_event = {
					id = mongol_invasion.0001
					days = { 2 240 }
				}
			}
		}
		else = {
			if = {
				limit = {
					current_date > 1180.1.1
					current_date < 1250.1.1
					NOT = { has_global_variable = mongols_have_appeared }
					#Greatest of khans hasn't come along
					NOT = { has_global_variable = greatest_of_khans_title }
					#Someone's not currently trying to be greatest of khans
					NOT = { has_global_variable = mpo_gok_war_ongoing }
					trigger_if = {
						limit = {
							game_start_date = 1178.10.1
						}
						years_from_game_start >= 20
					}
					#Temujin dying prevents Mongol invasion for at least 50 years
					NOT = {
						has_global_variable = temujin_failed
					}
				}
				debug_log = "Checking for chance of spawning mongols under historical settings"
				random = {
					chance = temujin_appearance_base_chance
					modifier = {
						add = 9
						current_date > 1200.1.1
					}
					modifier = {
						add = 10
						current_date > 1220.1.1
					}
					modifier = {
						add = 20
						current_date > 1235.1.1
					}
					modifier = {
						add = 30
						exists = character:125501 # Temüjin
						character:125501 = {
							is_physically_able_ai_adult = yes
						}
					}
					set_global_variable = {
						name = mongols_have_appeared
						value = yes
					}
					debug_log = "Attempting to spawn mongol invasion within 240 days"
					trigger_event = {
						id = mongol_invasion.0001
						days = { 2 240 }
					}
				}
			}
		}
		# Almohad Invasion
		if = {
			limit = {
				current_date >= 1110.1.1
				current_date < 1150.1.1
				NOT = { has_global_variable = spawned_almohads }
			}
			random = {
				chance = almohad_appearance_base_chance
				modifier = {
					add = 3
					current_date >= 1130.1.1
				}
				modifier = {
					add = 3
					current_date >= 1140.1.1
				}
				debug_log = "Attempting to spawn Almohads within 240 days"
				trigger_event = {
					id = almohad.0001
					days = { 2 240 }
				}
			}
		}
		# Jomsvikings form autonomously.
		if = {
			limit = {
				# Do we have the correct flavour pack?
				has_fp1_dlc_trigger = yes
				# Must be within the 10th century.
				current_date >= 900.1.1
				current_date < 1000.1.1
				# The Jomsvikings cannot have already formed for any reason & by any method.
				fp1_jomsvikings_have_not_existed_trigger = yes
				# Must be a valid target somewhere in the appropriate region.
				any_county_in_region = {
					region = dlc_fp1_region_non_scandinavian_southern_baltic
					holder = { fp1_ruler_eligible_for_jomsviking_coup = yes }
				}
			}
			random = {
				# Low initial chance, to give the player time.
				chance = 5
				# Add 5% every decade for the first half of the century.
				modifier = {
					add = 5
					current_date >= 910.1.1
				}
				modifier = {
					add = 5
					current_date >= 920.1.1
				}
				modifier = {
					add = 5
					current_date >= 930.1.1
				}
				modifier = {
					add = 5
					current_date >= 940.1.1
				}
				modifier = {
					add = 5
					current_date >= 950.1.1
				}
				# And then add another 25% solid chance for the whole of the latter half of the century.
				modifier = {
					add = 25
					current_date >= 960.1.1
				}
				# Fire the event.
				trigger_event = {
					id = fp1_jomsvikings.1011
					days = { 30 300 }
				}
			}
		}
		# A wandering French monk appears.
		if = {
			limit = {
				# Do we have the correct flavour pack?
				has_fp2_dlc_trigger = yes
				# Must be before the monk would likely die.
				current_date <= 880.1.1
				# The monk hasn't already tried to turn up somewhere.
				NOT = {
					is_target_in_global_variable_list = {
						name = unavailable_unique_events
						target = flag:lyonese_monk_event
					}
				}
			}
			# If there's a player in this region, we wait for one to become eligible.
			if = {
				limit = {
					any_player = {
						capital_province = { geographical_region = dlc_fp2_lyonese_monk_region }
					}
				}
				if = {
					limit = {
						OR = {
							any_player = {
								capital_province = { geographical_region = dlc_fp2_lyonese_monk_region }
								fp2_lyonese_monk_0002_valid_character_configuration_trigger = yes
							}
							current_date = 880.1.1
						}
					}
					# Fire the event.
					trigger_event = {
						id = fp2_lyonese_monk.0002
						days = { 30 90 }
					}
				}
			}
			# Otherwise, we roll randomly per year immediately.
			else_if = {
				limit = {
					any_county_in_region = {
						region = dlc_fp2_lyonese_monk_region
						holder = { fp2_lyonese_monk_0002_valid_court_trigger = yes }
					}
				}
				random = {
					# Low initial chance, to give the player time.
					chance = 5
					# Slowly ramp up the chance till *someone* is selected, assuming we have any valid candidates.
					modifier = {
						add = 20
						current_date >= 870.1.1
					}
					modifier = {
						add = 25
						current_date >= 873.1.1
					}
					modifier = {
						add = 25
						current_date >= 876.1.1
					}
					modifier = {
						add = 25
						current_date = 880.1.1
					}
					# Fire the event.
					trigger_event = {
						id = fp2_lyonese_monk.0002
						days = { 30 90 }
					}
				}
			}
		}
		
		# Rabbinicism becomes Monogamous
		if = {
			limit = {
				# Rabbi Gershom bans polygamy sometime in the 11th century
				current_date > "1000.01.01"
				# Make sure this hasn't happened already
				faith:rabbinism = {
					has_doctrine = doctrine_polygamy
					NOT = {
						has_variable = rabbinicism_accepted_monogamy
						has_variable = rabbinicism_rejected_monogamy
					}
				}
			}
			religion:judaism_religion = {
				every_faith = {
					limit = {
						has_doctrine = doctrine_polygamy
						has_doctrine = temple_authority_rabbinic_doctrine
					}
					if = {
						limit = {
							exists = religious_head
						}
						if = {
							limit = {
								religious_head = { is_independent_ruler = no }
								religious_head.top_liege.faith = this
							}
							religious_head.top_liege = { trigger_event = jewish_events.0001 }
						}
						else_if = {
							limit = {
								religious_head = { is_independent_ruler = no }
								religious_head.liege.faith = this
							}
							religious_head.liege = { trigger_event = jewish_events.0001 }
						}
						else = {
							religious_head = { trigger_event = jewish_events.0001 }
						}
					}
					else_if = {
						limit = {
							any_player = { # Checking players is more performant than checking faith characters and limiting it to players
								faith = prev
							}
						}
						random_player = {
							limit = { faith = prev }
							trigger_event = jewish_events.0001
						}
					}
					else = {
						random_faith_character = {
							trigger_event = jewish_events.0001
						}
					}
				}
			}
		}
		
		# The Rise of the Seljuk
		if = { limit = { has_game_rule = never_seljuk_invasion } }
		else_if = { # Random Seljuk Invasion
			limit = {
				has_game_rule = random_seljuk_invasion
				NOR = {
					exists = global_var:seljuk_invasion_happened
					exists = struggle:persian_struggle # We don't allow it during the struggle (not that it can happen in 930)
				}
			}
			random = {
				chance = fp3_seljuk_chance_of_appearance
				modifier = {
					add = 5
					current_date > 965.1.1
				}
				modifier = {
					add = 5
					current_date > 985.1.1
				}
				modifier = {
					add = 5
					current_date > 1005.1.1
				}
				modifier = {
					factor = 0.25
					OR = {
						culture:turkish = { culture_number_of_counties = 0 }
						faith:ashari = { has_followers_trigger = no }
					}
				}
				set_global_variable = {
					name = seljuk_invasion_happened
					value = yes
				}
				debug_log = "Attempting to spawn seljuk invasion within 240 days"
				trigger_event = {
					id = fp3_story_cycle_seljuks_invasion_events.0001
					days = { 2 240 }
				}
			}
		}
		else_if = { # Historical Seljuk Invasion
			limit = {
				current_date < 1066.1.1
				current_date >= 945.1.1
				NOR = {
					exists = global_var:seljuk_invasion_happened
					exists = struggle:persian_struggle # We don't allow it during the struggle (not that it can happen in 930)
				}
			}
			random = {
				chance = fp3_seljuk_chance_of_appearance
				modifier = {
					add = 5
					current_date > 965.1.1
				}
				modifier = {
					add = 5
					current_date > 985.1.1
				}
				modifier = {
					add = 5
					current_date > 1005.1.1
				}
				modifier = {
					factor = 0.25
					OR = {
						culture:turkish = { culture_number_of_counties = 0 }
						faith:ashari = { has_followers_trigger = no }
					}
				}
				set_global_variable = {
					name = seljuk_invasion_happened
					value = yes
				}
				debug_log = "Attempting to spawn seljuk invasion within 240 days"
				trigger_event = {
					id = fp3_story_cycle_seljuks_invasion_events.0001
					days = { 2 240 }
				}
			}
		}

		# Zanj Rebellion
		if = {
			limit = { 
				current_date = 868.1.2 
				NOT = { exists = global_var:zanj_rebellion_happened }
			}
			debug_log = "Zanj Rebellion Story Cycle Started"
			trigger_event = {
				id = fp3_story_cycle_zanj_rebellion_events.0001
				days = { 100 5000 }
			}
			set_global_variable = {
				name = zanj_rebellion_happened
				value = yes
			}
		}
		#Grant latin emperor a de jure kingdom after 100 years, if they've failed to grab any de jure lands yet
		if = {
			limit = {
				exists = global_var:byz_collapse_counter
				current_year >= global_var:byz_collapse_counter
				exists = title:e_latin_empire.holder
				title:e_latin_empire.holder = {
					is_alive = yes
					primary_title = title:e_latin_empire
					capital_county.kingdom = {
						empire = title:e_byzantium
						any_de_jure_county = {
							percent >= 0.5
							holder.top_liege = {
								this = title:e_latin_empire.holder
							}
						}
					}
				}
				NOT = {
					title:e_latin_empire = {
						any_in_de_jure_hierarchy = {
							tier <= tier_kingdom
						}
					}
				}
			}
			title:e_latin_empire.holder = {
				trigger_event = ep3_frankokratia_events.0140
			}
		}
		#Greek anarchy CB becomes unavailable when things are settled
		if = {
			limit = {
				exists = global_var:byz_collapse_counter
				current_year >= global_var:byz_collapse_counter
				OR = {
					NOT = {
						exists = title:e_latin_empire.holder
					}
					title:e_latin_empire.holder ?= {
						NOT = {
							any_realm_county = {
								OR = {
									empire = title:e_latin_empire
									empire = title:e_byzantium
								}
							}
						}
					}
					title:e_latin_empire.holder ?= {
						any_held_title = {
							this = title:e_byzantium
						}
					}
				}
			}
			remove_global_variable = byz_collapse_counter

			#Send notification out to everyone in de jure latin empire
			if = {
				limit = {
					title:e_latin_empire = {
						any_in_de_jure_hierarchy = {
							holder ?= {
								is_ai = no
							}
						}
					}
				}
				title:e_latin_empire = {
					every_in_de_jure_hierarchy = {
						limit = {
							holder ?= {
								is_ai = no
							}
						}
						if = {
							limit = {
								holder ?= {
									NOT = { is_in_list = latin_byz_notify }
								}
							}
							holder = {
								add_to_list = latin_byz_notify
							}
						}
					}
				}
			}
			if = {
				limit = {
					title:e_byzantium = {
						any_in_de_jure_hierarchy = {
							holder ?= {
								is_ai = no
							}
						}
					}
				}
				title:e_byzantium = {
					every_in_de_jure_hierarchy = {
						limit = {
							holder ?= {
								is_ai = no
							}
						}
						if = {
							limit = {
								holder = {
									NOT = { is_in_list = latin_byz_notify }
								}
							}
							holder = {
								add_to_list = latin_byz_notify
							}
						}
					}
				}
			}
			title:e_latin_empire.holder = {
				if = {
					limit = {
						is_ai = no
						NOT = { is_in_list = latin_byz_notify }
					}
					add_to_list = latin_byz_notify
				}
				trigger_event = ep3_frankokratia_events.0081
			}
			title:e_byzantium.holder = {
				if = {
					limit = {
						is_ai = no
						NOT = { is_in_list = latin_byz_notify }
					}
					add_to_list = latin_byz_notify
				}
			}
			title:e_byzantium = {
				save_scope_as = byzantium
			}
			if = {
				limit = {
					any_in_list = {
						list = latin_byz_notify
						count > 0
					}
				}
				every_in_list = {
					list = latin_byz_notify
					send_interface_message = {
						type = msg_frankokratia_anarchy_end
						title = msg_greek_anarchy_cb_loss.t
						desc = msg_greek_anarchy_cb_loss.desc
						right_icon = scope:byzantium
						custom_tooltip = lose_greek_anarchy_cb_tt
					}
				}
			}
			
		}
	}
	
	events = {
		shogunate_culture.0001	# Spread of the arquebus
		shogunate_yearly.0001	# Historical title change for baronies
	}

	on_actions = {
		inspiration_maintenance_global_pulse
	}
}

# Called from code once a year for "playable" (count+) characters.
# Root is the character
yearly_playable_pulse = {
	effect = {
		ai_budget_manipulation_effect = yes
		if = {
			limit = {
				government_has_flag = government_is_mercenary
				culture = {
					has_cultural_parameter = mercenary_courtiers_gain_extra_skills
				}
			}
			knight_increase_prowess_chance_effect = yes
			every_courtier = {
				limit = {
					is_knight = yes
				}
				knight_increase_prowess_chance_effect = yes
			}
		}
		# Assign or level up court type trait for courtiers in a royal court
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			assign_court_type_traits_to_courtiers_effect = yes
		}
		# Yurt domicile bonuses distribution
		if = {
			limit = {
				government_has_flag = government_is_nomadic
				exists = domicile
			}
			#Dynasty of Many Khans
			mpo_yearly_dynasty_of_many_khans_effect = yes
			
			#Yearly yurt rewards
			domicile ?= {
				if = {
					limit = {				
						OR = {
							has_domicile_building_or_higher = family_yurt_01
							has_domicile_building_or_higher = mystical_yurt_01
							has_domicile_building_or_higher = court_yurt_01
						}
					}
					mpo_yearly_yurt_rewards_effect = yes
				}
			}
		}

		# Yearly house head opinion update: to change into only one log maybe?
		if = {
			limit = {
				government_has_flag = government_is_clan
				exists = house
				is_house_head = yes
			}
			save_scope_as = unity_target
			if = {
				limit = {
					OR = {
						has_character_flag = steer_unity_towards_harmonious_passive_gain
						has_character_flag = steer_unity_towards_antagonistic_passive_loss
					}
				}
				house = {
					add_unity_value = {
						value = {
							if = {
								limit = { root = { has_character_flag = steer_unity_towards_harmonious_passive_gain } }
								add = medium_unity_gain
							}
							else = {
								add = medium_unity_loss
							}
						}
						character = root
						desc = clan_unity_steer_direction_passive_change.desc
					}
				}
			}
			else = {
				house = {
					set_variable = {
						name = house_opinion_unity_impact
						value = 0
					}
					every_house_member = {
						limit = {
							is_house_head = no
							is_adult = yes
						}
						if = {
							limit = {
								opinion = {
									target = scope:unity_target
									value >= low_positive_opinion
								}
							}
							prev = {
								change_variable = {
									name = house_opinion_unity_impact
									add = miniscule_unity_value
								}
							}
							if = {
								limit = {
									opinion = {
										target = scope:unity_target
										value >= high_positive_opinion
									}
								}
								prev = {
									change_variable = {
										name = house_opinion_unity_impact
										add = minor_unity_value
									}
								}

							}
						}
						else = {
							prev = {
								change_variable = {
									name = house_opinion_unity_impact
									subtract = miniscule_unity_value
								}
							}

							if = {
								limit = {
									opinion = {
										target = scope:unity_target
										value <= high_negative_opinion
									}
								}
								prev = {
									change_variable = {
										name = house_opinion_unity_impact
										subtract = minor_unity_value
									}
								}
							}
						}
					}
					if = {
						limit = { var:house_opinion_unity_impact != 0 }
						add_unity_value = {
							value = {
								if = {
									limit = { var:house_opinion_unity_impact > 0 }
									add = minor_unity_gain
								}
								else = {
									add = minor_unity_loss
								}
							}
							character = root
							desc = clan_unity_generic_average_yearly_opinion_house_head.desc
						}
					}
				}
			}
		}
		
		# ADMINISTRATIVE GOVERNMENT
		# Governor contract generation
		if = {
			limit = {
				is_governor = yes
				trigger_if = {
					limit = { is_ai = yes }
					is_available = yes
				}
			}
			random = {
				chance = {
					value = 70
					if = {
						limit = { has_character_flag = admin_governance_frequency_cooldown }
						subtract = 50
					}
				}
				spawn_governance_contract_effect = yes
			}
		}

		# Failsafe to ensure we don't get independent admin rulers of too low a rank (i.e. below king)
		if = {
			limit = {
				liege = root # I.e. root is independent
				government_has_flag = government_is_administrative
				highest_held_title_tier < tier_kingdom
			}
			if = { # If we are looking at an independent landless character, let's destroy their title
				limit = {
					is_landed = no
				}
				destroy_title = primary_title
			}
			else = { # Otherwise, they change government
				admin_change_government_effect = yes
				if = {
					limit = {
						any_held_title = {
							is_noble_family_title = yes
						}
					}
					every_held_title = {
						limit = {
							is_noble_family_title = yes
						}
						save_temporary_scope_as = family_title
						root = { destroy_title = scope:family_title }
					}
				}
			}
		}
		# Failsafe to ensure we don't have a noble family holding land without other titles - Give any held land to liege
		if = {
			limit = {
				government_has_flag = government_is_administrative
				is_landed = yes
				exists = liege
				NOT = { liege = root }
				any_held_title = { # They have a noble family title
					is_noble_family_title = yes
				}
				NOT = { # And no other high tier titles
					any_held_title = {
						tier >= tier_duchy
						is_noble_family_title = no
					}
				}
			}
			create_title_and_vassal_change = {
				type = revoked
				save_scope_as = change
				add_claim_on_loss = no
			}
			every_held_title = {
				limit = {
					tier = tier_county
				}
				add_to_list = revoked_titles
			}
			every_in_list = {
				list = revoked_titles
				change_title_holder_include_vassals = {
					holder = root.liege
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		
		if = {
			limit = {
				has_character_flag = tournament_ai_override
			}
			ai_attempt_to_host_activity = activity_tournament
		}
		else_if = {
			limit = {
				has_character_flag = feast_ai_override
			}
			ai_attempt_to_host_activity = activity_feast
		}

		# Scalable Modifiers which needs to be reapplied
		hidden_effect = {
			if = {
				limit = {
					has_character_modifier = church_investment_modifier
				}
				remove_character_modifier = church_investment_modifier
				add_character_modifier = church_investment_modifier
			}
		}
		if = {
			limit = {
				has_perk = learn_on_the_job_perk
				is_landless_adventurer = yes
			}
			every_courtier = {
				limit = {
					is_physically_able_adult = yes
					NOT = { exists = inspiration }
				}
				random = {
					chance = {
						value = 0
						add = {
							value = book_inspiration_average_skill_value
							if = {
								limit = {
									has_trait = lazy
								}
								multiply = 0.5
							}
							if = {
								limit = {
									root = {
										any_courtier = {
											exists = inspiration
										}
									}
								}
								multiply = 0.5
							}
						}
					}
					create_inspiration = book_inspiration
					save_scope_as = inspired_follower
					root = {
						send_interface_message = {
							type = send_interface_message_good
							title = adventurers_gather_inspiration_option.title
							left_icon = scope:inspired_follower
							scope:inspired_follower = {
								custom_tooltip = {
									text = adventurers_gather_inspiration_option.effect
								}
							}
						}
					}
				}
			}
		}
		# AI Adventurer contract logic setup
		if = {
			limit = {
				ep3_adventurer_ai_logic_valid_trigger = yes
				NOT = { owns_story_of_type = story_adventurer_ai }
			}
			create_story = { type = story_adventurer_ai }
		}
		if = { # If a player adventurer manages to glitch in place, save them by moving them to the domicile location
			limit = {
				is_ai = no
				is_landless_adventurer = yes
				NOT = {
					location = domicile.domicile_location
				}
				is_imprisoned = no
				is_travelling = no
				NOT = {
					exists = involved_activity
				}
				num_taken_task_contracts <= 0
				is_commanding_army = no
			}
			set_location_to_default = yes
		}
		if = {	
			limit = {
				NOT = {
					top_liege ?= {
						is_confederation_member = yes
					}
				}
				has_character_modifier = mpo_confederation_member_modifier
			}
			remove_character_modifier = mpo_confederation_member_modifier
		}
		# Stray player Herders get turned into Nomads
		if = {
			limit = {
				is_ai = no
				government_has_flag = government_is_herder
			}
			every_held_title = {
				limit = {
					tier = tier_county
					title_province = {
						has_holding_type = herder_holding
					}
				}
				title_province = {
					set_holding_type = nomad_holding
				}
			}
			change_government = nomad_government
		}
		
		######################
		# Various safeguarding against realm setups with landless participants
		######################
		if = {
			limit = {
				is_landed = no
			}
			
			save_scope_as = scoped_ruler
			
			######################
			# Repair realms with Landless participants having vassals
			######################
			
			if = {
				limit = {
					any_sub_realm_county = {
						is_landless_type_title = no
					}
				}
				
				######################
				# Landless Lieges with Landed Vassals should take a County from a Vassal
				######################
				
				if = {
					limit = { # Make sure we repair realms in the right order
						OR = {
							this = top_liege
							liege ?= {
								is_landed = yes
							}
						}
					}
					create_title_and_vassal_change = {
						type = revoked
						save_scope_as = change
					}
					random_sub_realm_county = {
						limit = {
							is_landless_type_title = no
						}
						weight = {
							modifier = {
								add = 100
								this = scope:scoped_ruler.primary_title.title_capital_county
							}
							modifier = {
								add = -100
								holder = {
									is_ai = no
								}
							}
						}
						change_title_holder = {
							holder = scope:scoped_ruler
							change = scope:change
						}
					}
					resolve_title_and_vassal_change = scope:change
					
					######################
					# Landless vassals with Landed vassals should take something and become landed
					######################
					
					every_vassal = {
						limit = {
							is_landed = no
							any_sub_realm_county = {
								is_landless_type_title = no
							}
						}
						save_scope_as = vassal_ruler
						create_title_and_vassal_change = {
							type = revoked
							save_scope_as = change
						}
						random_sub_realm_county = {
							limit = {
								is_landless_type_title = no
							}
							weight = {
								modifier = {
									add = 100
									this = scope:vassal_ruler.primary_title.title_capital_county
								}
								modifier = {
									add = -100
									holder = {
										is_ai = no
									}
								}
							}
							change_title_holder = {
								holder = scope:vassal_ruler
								change = scope:change
							}
						}
						resolve_title_and_vassal_change = scope:change
					}
				}
			}
			
			######################
			# Destroy the AI's landless nomad vassals, as they'll just bloat the game for no gain
			######################
			
			else_if = {
				limit = {
					is_ai = yes
					top_liege != this
					government_has_flag = government_is_nomadic
					is_landed = no
					liege = { is_ai = yes }
				}
				every_held_title = {
					limit = {
						is_nomad_title = yes
					}
					scope:scoped_ruler = {
						destroy_title = prev
					}
				}
			}
			# Players become independent so they can migrate
			else_if = {
				limit = {
					is_ai = no
					top_liege != this
					government_has_flag = government_is_nomadic
					is_landed = no
					liege = { is_ai = yes }
				}
				create_title_and_vassal_change = {
					type = independency
					save_scope_as = change
					add_claim_on_loss = no
				}
				becomes_independent = { change = scope:change }
				resolve_title_and_vassal_change = scope:change
			}
			
			######################
			# AI's with a Nomadic Camp title that somehow end up with the wrong government and landless should be purged
			######################
			
			if = {
				limit = {
					NOT = { government_has_flag = government_is_nomadic }
					any_held_title = {
						is_nomad_title = yes
					}
				}
				save_scope_as = scoped_ruler
				if = {
					limit = {
						is_ai = yes
					}
					every_held_title = {
						limit = {
							is_nomad_title = yes
						}
						scope:scoped_ruler = {
							destroy_title = prev
						}
					}
				}
				# Players are saved
				else_if = {
					limit = {
						is_ai = no
					}
					change_government = nomad_government
				}
			}
			
			######################
			# Landless nomads outside any migration area? Cleanup.
			######################
			
			if = {
				limit = {
					is_ai = yes
					top_liege = this
					NOT = {
						any_character_situation = {
							any_participant_group = {
								participant_group_type = nomad_rulers_capital
								participant_group_has_character = scope:scoped_ruler
							}
						}
					}
					any_held_title = {
						is_nomad_title = yes
					}
				}
				every_held_title = {
					limit = {
						is_nomad_title = yes
					}
					scope:scoped_ruler = {
						destroy_title = prev
					}
				}
			}
		}

		# ACH AI vibe checks
		if = {
			limit = {
				has_realm_law = uncrowned
				is_ai = yes
			}
			# Why are you like this, get rid of the crowned variables
			if = {
				limit = {
					has_variable = crowned_king_var
				}
				remove_variable = crowned_king_var
			}
			else_if = {
				limit = {
					has_variable = crowned_emperor_var
				}
				remove_variable = crowned_emperor_var
			}
			#Try removing them from their army to make them available
			if = {
				limit = {
					is_in_army = yes
					martial <= medium_skill_rating
					location ?= {
						any_army_in_location = {
							is_army_in_combat = no
						}
					}
					NOR = {
						any_war_enemy = {
							is_ai = no
						}
						any_war_ally = {
							is_ai = no
						}
					}
				}
				location = {
					random_army_in_location = {
						limit = {
							army_commander = root
						}
						remove_commander = yes
					}
				}
			}
			#Do you need an artifact?
			if = {
				limit = {
					can_host_activity = activity_coronation
					coronation_has_proper_artifact_trigger = no
				}
				random = {
					chance = coronation_artifact_ai_instant_creation_chance
					coronation_create_artifact_yearly_effect = yes
				}
			}

			#If you need to be anointed...
			#First step is being un-excommunicated
			if = {
				limit = {
					highest_held_title_tier >= tier_empire
					has_trait = excommunicated
					faith = {
						has_doctrine = doctrine_spiritual_head
						has_doctrine = doctrine_imperial_anointment
					}
					custom_tooltip = {
						text = anointment_request_already_supported
						NOT = {
							is_target_in_variable_list = {
								name = supported_anointments
								target = scope:actor
							}
						}
					}
					is_character_interaction_valid = {
						recipient = faith.religious_head
						interaction = declaration_of_repentance_interaction
					}
				}
				run_interaction = {
					interaction = declaration_of_repentance_interaction
					actor = this
					recipient = faith.religious_head
					execute_threshold = maybe
				}
			}
			#Next step is getting approval
			else_if = {
				limit = {
					exists = faith.religious_head
					is_character_interaction_valid = {
						recipient = faith.religious_head
						interaction = coronation_anointment_request
					}
					faith = {
						has_doctrine = doctrine_spiritual_head
						has_doctrine = doctrine_imperial_anointment
					}
				}
				run_interaction = {
					interaction = coronation_anointment_request
					actor = this
					recipient = faith.religious_head
					execute_threshold = maybe
				}
			}
			#Next step is hosting the dang coronation
			else = {
				ai_attempt_to_host_activity = activity_coronation
				debug_log = "AI attempted to host a coronation"
				debug_log_scopes = yes
			}
		}
	}
	events = {
		court_maintenance.0012 # Dynasty banner improves with renown
		court_maintenance.0013 # Remove duplicate dynasty banners
		shogunate_culture.0011 # Spread of the cannon
	}
	on_actions = {
		ai_character_pulse
		delay = { days = 75 }

		pagan_conversion_pulse
	}
}

# Called from code once every three years for "playable" (count+) characters.
# Root is the character
three_year_playable_pulse = {
	events = {
		adultery.0001 #Suspected spouse/soulmate of cheating (increased chance when there is a lover, but can also trigger otherwise)
	}
	random_events = {
		800 = 0
		200 = global_culture.3011
		600 = global_culture.3012
	}
	effect = {
		if = { # Nomadic herd starves if you're landless
			limit = {
				is_landed = no
				government_has_flag = government_is_nomadic
				exists = domicile
				is_migrating = no
				is_at_war = no
			}
			if = {
				limit = {
					domicile.herd > 500
				}
				change_current_weight = -25
				every_courtier = {
					change_current_weight = -25
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = herd_starvation_title
					left_icon = root
					custom_tooltip = herd_starvation_custom_tooltip
					domicile ?= {
						change_herd = {
							value = root.domicile.herd
							divide = 3
							min = 500
							if = {
								limit = {
									root = { is_ai = yes }
								}
								min = 1000
							}
							multiply = -1
						}
					}
				}
			}
			clean_up_ai_nomad_effect = yes
		}
		if = { # Various nomadic safeguards
			limit = {
				is_landed = yes
				NOR = {
					government_has_flag = government_is_nomadic
					government_has_flag = government_is_herder
				}
			}
			
			save_scope_as = scoped_ruler
			
			######################
			# Nomadic titles that end up with non-nomadic holders are destroyed
			######################
			if = {
				limit = {
					any_held_title = {
						is_nomad_title = yes
					}
				}
				every_held_title = {
					limit = {
						is_nomad_title = yes
					}
					scope:scoped_ruler = {
						destroy_title = prev
					}
				}
			}
			
			######################
			# Anyone who *only* holds Nomadic lands should become Nomadic
			######################
			
			if = {
				limit = {
					highest_held_title_tier >= tier_county
					capital_province = {
						OR = {
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
					NOT = {
						any_held_title = {
							tier = tier_county
							is_landless_type_title = no
							title_province = {
								NOR = {
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
						}
					}
				}
				every_held_title = {
					limit = {
						tier = tier_county
						title_province = {
							has_holding_type = herder_holding
						}
					}
					title_province = {
						set_holding_type = nomad_holding
					}
				}
				change_government = nomad_government
				
				# We don't want overly-funky nomad camps to spring up, so set an appropriate culture/faith
				if = {
					limit = {
						domicile.domicile_culture != capital_county.culture
					}
					domicile = {
						set_domicile_culture = scope:scoped_ruler.capital_county.culture
					}
				}
				if = {
					limit = {
						domicile.domicile_faith != capital_county.faith
					}
					domicile = {
						set_domicile_faith = scope:scoped_ruler.capital_county.faith
					}
				}
			}
		}
		else_if = {
			limit = {
				government_has_flag = government_is_nomadic
				is_ruler = yes
			}
			
			save_scope_as = scoped_ruler
			
			######################
			# If you end up losing your Nomadic Capital, get a new one
			######################
			
			if = {
				limit = {
					NOT = {
						any_held_title = {
							is_nomad_title = yes
						}
					}
				}
				create_nomad_title = {
					name = nomad_title_name
					holder = scope:scoped_ruler
					government = nomad_government
					save_scope_as = new_nomad_title
				}
				domicile ?= {
					add_domicile_building = yurt_main_02
					add_domicile_building = yurt_main_03
					add_random_yurt_external_building_effect = yes
					add_random_yurt_external_building_effect = yes
					upgrade_random_yurt_external_building_effect = yes
					upgrade_random_yurt_external_building_effect = yes
				}
			}
			
			######################
			# If your nomadic capital domicile somehow gets lost, move it to your capital province
			######################
			
			if = {
				limit = {
					is_at_war = no
					exists = domicile
					domicile.domicile_location != capital_province
				}
				domicile = { move_domicile = scope:scoped_ruler.capital_province }
			}
		}
	}
}

# Called from code once every five years for "playable" (count+) characters.
# Root is the character
five_year_playable_pulse = {
	effect = {
		ai_chance_to_become_conqueror_effect = yes
		# Special Holy Seeds drops
		if = {
			limit = {
				has_dlc_feature = legends
				piety_level >= very_high_piety_level
				NOT = { has_variable = saintly_deed_var }
				NOR = { 
					has_game_rule = historical_legends_only 
					has_personal_legend_seed = holy
				}
			}
			random = {
				chance = 10
				send_interface_toast = {
					title = holy_seed_toast_traits
					left_icon = root
					set_variable = saintly_deed_var
					create_legend_seed = {
						type = holy
						quality = famed
						chronicle = saintly_life
						properties = {
							religion = root.religion
						}
					}
				}
			}
		}
#		chance_for_random_nickname_effect = yes
		ai_chance_to_switch_to_travel_focus_effect = yes
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			every_courtier = {
				limit = {
					is_available_ai = yes
					age > 6
					NOT = {
						knows_court_language_of = host
					}
				}
				random = {
					chance = {
						value = -4
						add = learning
						if = {
							limit = {
								is_adult = no
							}
							add = 4
						}
						if = {
							limit = {
								host = {
									employs_court_position = court_tutor_court_position
								}
							}
							add = 2
						}
						if = {
							limit = {
								host = {
									has_court_type = court_diplomatic
								}
							}
							add = 2
						}
						if = {
							limit = {
								host = {
									has_court_type = court_scholarly
								}
							}
							add = 4
						}
					}
					learn_court_language_of = host
				}
			}
			if = {
				limit = {
					employs_court_position = court_poet_court_position
				}
				every_court_position_holder = {
					type = court_poet_court_position
					limit = {
						is_physically_able_adult = yes
						ep1_is_valid_character_for_inspiration_trigger = yes
					}
					random = {
						chance = {
							value = 5
							add = {
								value = this.aptitude:court_poet_court_position
								multiply = 5
								if = {
									limit = {
										has_trait = lazy
									}
									multiply = 0.5
								}
							}
						}
						grant_inspiration_to_character_effect = { CHARACTER = this }
						save_scope_as = inspired_poet
						root = {
							send_interface_toast = {
								type = msg_court_inspiration
								left_icon = scope:inspired_poet
								title = poet_inspired_message
								desc = poet_inspired_effect
							}
						}
					}
				}
			}
			if = {
				limit = {
					employs_court_position = court_artificer_court_position
				}
				every_court_position_holder = {
					type = court_artificer_court_position
					limit = {
						is_physically_able_adult = yes
						ep1_is_valid_character_for_inspiration_trigger = yes
						NOT = { has_character_flag = regular_inspiration_block }
					}
					random = {
						chance = {
							value = 5
							add = {
								value = this.aptitude:court_artificer_court_position
								multiply = 5
								if = {
									limit = {
										has_trait = lazy
									}
									multiply = 0.5
								}
							}
						}
						grant_inspiration_to_character_effect = { CHARACTER = this }
						save_scope_as = artificer
						root = {
							send_interface_toast = {
								type = msg_court_inspiration
								left_icon = scope:artificer
								title = poet_inspired_message
								desc = court_artificer_inspired_effect
							}
						}
					}
				}
			}
		}
		if = {
			limit = {
				cp:councillor_court_chaplain ?= {
					is_theocratic_lessee = yes
					NOT = {
						knows_language_of_culture = root.culture
					}
				}
			}
			cp:councillor_court_chaplain = {
				random_list = {
					10 = {
						modifier = {
							add = learning
						}
						learn_language_of_culture = root.culture
					}
					5 = {
						trigger = {
							can_start_scheme = { type = learn_language target_character = root }
						}
						start_scheme = {
							type = learn_language
							target_character = root
						}
					}
				}
			}
		}
	}
	events = {
		courtier_guest_management.3001 	# Courtiers and guests getting relationships & secrets
#		game_rule.1 					# De Jure Requirement Game Rule
#		game_rule.4 					# Empire Obscurity Game Rule
	}
	on_actions = {
		delay = { days = { 45 75 } }
		culture_hybridization_emergence_events
		delay = { days = { 45 75 } }
		culture_divergence_emergence_events
	}
}

# Called from code once a quarter for "playable" (count+) characters.
# Root is the character
# scope:quarter is which quarter it's for, from 1 to 4. Note that scope:quarter = 1 isn't necessarily in Q1 by calendar time
quarterly_playable_pulse = {
	on_actions = {
		realm_maintenance_quarterly_pulse

		# Event pools
		stewardship_lifestyle_progress_pulse
		intrigue_lifestyle_progress_pulse
		diplomacy_lifestyle_progress_pulse
		martial_lifestyle_progress_pulse
		learning_lifestyle_progress_pulse
		wanderer_lifestyle_progress_pulse

		# Relation pulses are spread out across the four quarterly pulses a year
		lover_quarterly_pulse
		friendship_quarterly_pulse
		rival_quarterly_pulse
		mentor_student_quarterly_pulse

		# EP1 maintenance pulses
		inspiration_maintenance_quarterly_pulse

		# MPO
		mpo_season_events_quarterly_playable_pulse
		mpo_tributary_check_pulse
	}
	random_on_action = {
		chance_to_happen = 75
		100 = ep3_yearly_events_laamps
	}
}

# Called from code once a year for all "playable" characters, at a random point that year (individually for each character). Different time from the random_yearly_everyone_pulse (coincides by random 1 time out of 365)
# Root is the character
random_yearly_playable_pulse = {
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
	}
	random_on_action = {
		chance_of_no_event = {
			value = 0
			if = {
				limit = {
					is_ai = yes
					highest_held_title_tier < tier_duchy
				}
				add = 75 # AI counts aren't particularly important
			}
		}
		6 = on_yearly_events
		5 = fp1_yearly_events
		4 = fp2_yearly_events
		4 = fp3_yearly_events
		2 = bp1_yearly_events
		6 = ep3_yearly_events_byzantium
		6 = ep3_yearly_events_admin
		10 = mpo_yearly_events_nomads
	}
	effect = {
		# Special Holy Seeds drops
		if = {
			limit = {
				has_dlc_feature = legends
				OR = {
					has_trait = theologian
					has_trait = sayyid
				}
				NOR = {
					has_game_rule = historical_legends_only
					has_personal_legend_seed = holy
				}
			}
			random = {
				chance = 15
				send_interface_toast = {
					type = msg_legend_seed_created
					title = holy_seed_toast_traits
					left_icon = root
					create_legend_seed = {
						type = holy
						quality = famed
						chronicle = saintly_life
						properties = {
							religion = root.religion
						}
					}
				}
			}
		}
		# Commander Trait Leveling for AI
		if = {
			limit = {
				is_ai = yes
				OR = {
					has_commander_trait_trigger = yes
					any_knight = {
						has_commander_trait_trigger = yes
					}
				}
			}
			commander_trait_lvling_ai_effect = yes
			every_knight = {
				limit = {
					is_ai = yes
					has_commander_trait_trigger = yes
				}
				commander_trait_lvling_ai_effect = yes
			}
		}
	}
	on_actions = {
		delay = { days = { 45 75 } }
		on_yearly_common_events	
		delay = { days = { 50 80 } }
		on_yearly_invisible_events
		delay = { days = { 85 165 } }
		bishop_ongoing
		delay = { days = { 166 185 } }
		wet_nurse_pulse
		delay = { days = { 51 180 } }
		childhood_ongoing
		delay = { days = { 51 180 } }
		hunt_sighting_on_action
		delay = { days = { 181 240 } }
		bp2_child_pulse
		delay = { days = { 181 240 } }
		bp2_parent_guardian_hostage_taker_pulse
		delay = { days = { 241 290 } }
		bp2_adult_followups
		delay = { days = { 291 310 } }
		court_scholar_ongoing
		delay = { days = { 25 44 } }
		clan_events_on_action
		ep3_akolouthos_on_action
		delay = { days = { 25 44 } }
		mpo_migration_contract
		delay = { days = { 1 180 } }
		mpo_migration_contract
		delay = { days = { 181 360 } }
		mpo_de_jure_shift
		delay = { days = { 1 60 } }
	}
}

# Called from code once a year for all characters, at a random point that year (individually for each character)
# Root is the character
random_yearly_everyone_pulse = {
	on_actions = {
		yearly_health_pulse
		stress_pulse
		prison_maintenance_pulse
	}
	random_on_action = {
		chance_of_no_event = {
			value = 95
		}
		1 = assign_trait_events
	}
	events = {
		holy_order.0206 #To increment the years passed since loan
		marriage_interaction.0007 #One of the betrothed became part of clergy that doesn't allow marriage
	}
	random_events = {
		500 = 0
		100 = holy_order.0202 #Holy order demands payment
	}
}

# Called from code once every five years for all characters.
# Root is the character
five_year_everyone_pulse = {
	effect = {
		# Herders may become Seasoned Pastoralists
		root = {
			if = {
				limit = {
					government_has_flag = government_is_herder
					NOT = { has_trait = lifestyle_seasoned_pastor }
					age >= 30
				}
				random = {
					chance = 20
					add_trait = lifestyle_seasoned_pastor
				}
			}
		}
				
		root = {
			if = { # Non-lowborn Barons should marry and produce a family
				limit = {
					exists = primary_title
					primary_title.tier = tier_barony
					is_adult = yes
					is_married = no
					is_lowborn = no
					can_marry_trigger = yes
					is_concubine = no
				}
				
				if = {
					limit = {
						exists = root.location
						any_pool_character = {
							province = location
							can_have_children_with = { CHARACTER = root }
							is_physically_able_adult = yes
							age <= 40
							is_married = no
							can_marry_trigger = yes
							is_concubine = no
							is_claimant = no
						}
					}
					random_pool_character = {
						province = root.location
						limit = {
							can_have_children_with = { CHARACTER = root }
							is_physically_able_adult = yes
							age <= 40
							is_married = no
							can_marry_trigger = yes
							is_concubine = no
							is_claimant = no
						}
						save_temporary_scope_as = spouse
					}
				}
				else = {
					create_character = {
						location = root.location
						template = pool_repopulate_spouse
						save_temporary_scope_as = spouse
					}
				}

				if = {
					limit = {
						is_female = yes
						scope:spouse = {
							is_lowborn = yes
						}
					}
					marry_matrilineal = scope:spouse
				}
				else = {
					marry = scope:spouse
				}
			}
			
			if = { # Long term gold is pointless for Barons - add it to short term instead
				limit = {
					is_ai = yes
					highest_held_title_tier = tier_barony
					gold > 0
					long_term_gold > 0
				}
				move_budget_gold = { gold = long_term_gold from = budget_long_term to = budget_short_term }
			}

			# FP2 - Checks to start El Cid's Travels
			if = {
				limit = { # Am I El Cid?
					has_fp2_dlc_trigger = yes
					has_ep3_dlc_trigger = no
					this = character:107590
					NOT = { has_character_flag = has_already_begun_travelling } # Separate first check, for performance

					NOT = { # Start date employer is either dead or gone
						OR = {
							top_liege = character:107500
							liege = character:107500
							employer = character:107500
						}
					}
					is_available_healthy_ai_adult = yes # Am I ready to go on an adventure?
				}
				trigger_event = fp2_struggle.2045
			}
			#young nobodies getting castrated
			if = {
				limit = {
					ep3_ai_castration_target_trigger = yes
				}
				trigger_event = ep3_yearly.3000
			}
		}
	}
	on_actions = {
		disease_outbreak_pulse # moved from health_on_actions.txt
	}
	events = {
		murder_scheme_maintenance.1 # Murder schemes for the AI, including unlanded characters
	}
}

# Called from code once every 3 years for pool characters
# root = the character
three_year_pool_pulse = {
	trigger = {
		is_pool_character = yes # Can cease to be in the pool between it queuing and executing
	}
	events = {
		courtier_guest_management.2001 #"Develops" the character and gives those without location a location
	}
	random_events = {
		chance_to_happen = 25
		chance_of_no_event = { # throttle wanderer Adventurers because they're simply less interesting
			if = {
				limit = {
					has_global_variable_list = laamps_tally
					global_variable_list_size = {
						name = laamps_tally
						value > seventyfive_percent_of_max_desired_laamps_value
					}
				}
				value = 100
			}
		}
		100 = courtier_guest_management.4001 # Wanderer becomes an adventurer
	}
}

#Only triggered if you actually have prisoners
prison_maintenance_pulse = {
	trigger = {
		any_prisoner = { count >= 1 }
	}
	on_actions = {
		#Set up quarterly pulses
		delay = { days = 45 }
		quarterly_prison_maintenance_pulse
		delay = { days = 135 }
		quarterly_prison_maintenance_pulse
		delay = { days = 225 }
		quarterly_prison_maintenance_pulse
		delay = { days = 315 }
		quarterly_prison_maintenance_pulse
	}
}


#Pulse for various AI stuff
ai_character_pulse = {
	trigger = {
		is_ai = yes
	}
	random_events = {
		chance_to_happen = 25
		500 = 0
		100 = learn_commander_trait.0001
		100 = holy_order.0100 #Give pilgrim trait to holy order members
	}
}

culture_hybridization_emergence_events = {
	random_events = {
		95 = 0
		5 = culture_emergence_events.0001 # Create a hybrid culture with your capital culture
	}
}

culture_divergence_emergence_events = {
	random_events = {
		199 = 0
		1 = culture_emergence_events.0002 # Create a divergent culture
	}
}

on_yearly_common_events = {
	random_events = {
		chance_to_happen = 50
		1000 = 0
		300 = lover.0003 #Too many lovers - break up with one?
		90 = language_events.0001 #Too many known languages - forget one?
		10 = language_events.0010 #Owl version of Too many known languages - forget one?
		200 = parent.0001 #parent_meddling_value_effect decreases over time
		200 = childhood.2010 # Convince ward they owe you
		50 = relation_upgrade.3000 # Vengeful character gains a rival, also for Cultural Tradition more rivals
		#Adultery events
		50 = adultery.2001 #Is the father suspicious of child or not?
		10 = adultery.3001 #Mother tells child the secret about them
		10 = culture_tradition_events.2000 # Vassal Gain Loyal Trait
		10 = culture_tradition_events.2001 # Vassal Gain Disloyal Trait
		100 = culture_tradition_events.2100 # Storytelling cultural tradition
	}
}

# Accolades yearly events
three_year_playable_pulse = {
	events = {
		ep2_accolade_events.0100 #Huntsmaster gives you or heir Hunter trait event
		ep2_accolade_events.0200 #Blademaster gives you or heir Blademaster trait event
		ep2_accolade_events.0300 #Master of Revels gives you or heir Reveler trait event
		ach_maintenance_events.0002 # ACH Oath synergy culture rewards
	}
}

on_yearly_invisible_events = {
	random_events = {
		chance_to_happen = 5
		150 = 0
		100 = secrets.1004 #Courtier learns another courtier's minor secret
		50 = secrets.1005 #A Courtier learns another courtier's major secret
	}
}

on_yearly_events = {
	random_events = {
		chance_to_happen = 25
		200 = 0

		50 = yearly.0001 	#Skill Tutoring
		100 = yearly.0002	#Indiscreet Councillor
		10 = yearly.0003	#Forbidden Love
		25 = yearly.0011	#Comet Sighted!

		75 = yearly.1001 	#Someone else's spouse makes a move at you
		50 = yearly.1010 	#Person you care about is abducted by rival
		15 = yearly.1020 	#High-up ruler wants you to deal with pesky enemy
		100 = yearly.1030 	#Someone you have hooked offers up other character's secret
		50 = yearly.1040 	#Courtier is hiding a letter - surprise or secret?
		100 = yearly.1050	#Heir fancies themselves a duelist
		100 = yearly.1060	#The oldest joke in the book
		100 = yearly.1070  	#Someone is your potential soulmate
		100 = yearly.1080	#You are being paranoid
#		100 = yearly.1090	#Foreign guests

		80 = yearly.3001 	#Dedication to Loyalty
		100 = yearly.3011 	#An Impression Twice Made
		100 = yearly.3021 	#On Their Deathbed
		100 = yearly.3031 	#Getting Ahead
		50 = yearly.3040	#A Good FaithPracticioner
		100 = yearly.3041	#Chafing Under Secular Laws
		100 = yearly.3051	#By Right
		50 = yearly.3061	#Cagots
		5 = yearly.3071		#A terrible nightmare
		5 = party_baron.0001 # Start the Party Baron story cycle

		100 = yearly.4001 	#A powerful vassal has angered neighboring ruler
		100 = yearly.4011 	#Heir is spending a lot of time with one of your powerful vassals
		10 = yearly.4021	#Mamaaaa, just killed a child
		10 = yearly.4031	#Who keeps leaving dead bodies all around the castle?!
		20 = yearly.4051	#Get a gift from a neighboring ruler (triggered here so you can't know for sure if someone has a scheme towards you)

		100 = yearly.5001 	#Catching Lover and Spouse fighting.
		100 = yearly.5010	#Vassal shows compassion to stressed/sick ruler, incurs in the jealousy of another vassal
		100 = yearly.5020	#Councilor offers to teach heir
		100 = yearly.5030	#Powerful Vassal offers to reveal secret of other Powerful Vassal to liege.
		100 = yearly.5040	#Two unimportant courtiers caught talking about powerful vassal.
		100 = yearly.5050	#Spouse feels slighted by courtier.

		10 = stress_trait_coping_decisions.2002 #Your stuff got stolen by a person in  a brothel!

		100 = yearly.7001	#Faction attempts a coup or kidnapping

		10 = yearly.7010	#Opportunity to participate in a football game

		10 = yearly.7050 	#Foggy Hill
		
		200 = major_decisions.2011	#Gain a scholar character if you have a University in your sub-realm
		
		#'Nice' events (positive effects)
		100 = yearly.8000 	# Vassal offers liege a gift
		100 = yearly.8100 	# The peasantry of a Domain province gives you a gift
		100 = yearly.8200 	# Your realm priest offers you part of a large donation
		100 = yearly.8300 	# A group of vassals collectively wish to contribute to your war effort
		20 = yearly.8400	# Discover a guest's Deviant secret (Strong Hook), and get the potential to send them to a rival's court
		300 = yearly.8500	# Your Head of Faith sends you a gift if you're fighting heathens

		#Ai value events
		100 = trait_specific_ongoing.2010 	# Positive zeal: which god/saint is talking to me?
		100 = witch.4001					# Negative zeal: annoying clergy

		# Stress Events
		100 = stress_trait_ongoing.0501 # A relaxing evening with some hashish cakes.
		100 = stress_trait_ongoing.0506 # Self-medicating pain away with hashish.
		100 = stress_trait_ongoing.0511 # An elderly person laments the follies of hashish-consuming youth.
		100 = stress_trait_ongoing.0516 # You zone out whilst eating hashish in an important meeting.
		100 = stress_trait_ongoing.1501 # Rake fantasizes about courtier.
		100 = stress_trait_ongoing.4501 # Comfort Eater runs out of favorite food.
		100 = stress_trait_ongoing.4502 # Cannibal needs to satisfy their craving!
		100 = stress_trait_ongoing.5001 # Inappetetic has a important character prepare a feast for them.
		
		#Elephant events for India
		300 = yearly.9020 # A Mighty Elephant

		# Tribal events
		100 = tribal.1101 #Holmgang with a rival
		100 = tribal.1201 #Horse Racing
		100 = tribal.1301 #Crocodile Encounter
		100 = tribal.1303 #Irrigate Oasis

		#Clan events
		150 = clan.1001 #Powerful vassal requests marriage
		150 = clan.1011 #A vassal asks for a perk
		150 = clan.1101 #Vassal Resents Nepotism
		100 = clan.1201 #Culture seeks Representation

		#Muslim-specific events (mostly about Islamic centers of learning)
		200 = yearly.4061 #A wise man visits your court
		200 = yearly.4071 #You're very educated!
		200 = yearly.4081 #Sponsor the translation of a book from Greek
		200 = yearly.4091 #Your ward and you visit scholars

		# Saharan regional flavour events.
		## Marginally bumped some weightings for regional effect.
		500 = yearly_saharan.0001 # An organised faith's merchants try to convert a pagan county in your domain.
		500 = yearly_saharan.0021 # Desert nomads wish to move to one of your non-nomadic Saharan counties.
		300 = yearly_saharan.0031 # Local slave raids intensify (aggressor).
		300 = yearly_saharan.0032 # Local slave raids intensify (defender).

		# Persion regional flavor events
		400 = yearly_persian.1001 # Nowruz, or Persian New Year
#		400 = yearly_persian.1101 # Shu'ubiyya, or Persian Nationalism (From the foreign side)

		# Varangian Guard
		400 = varangian.0001 # A Courtier wants to join the Varangian Guard

		#Pet story cycles
		20 = pet_animal.5001 # Rival has cat...
		20 = pet_animal.5002 # Rival has dog...

		#Holy Order
		100 = holy_order.2001 # Child wishes to join Holy Order
		100 = holy_order.2002 # Sibling wants to join a Holy Order
		200 = holy_order.2003 # Holy Order suggests you send them a child
		1000 = holy_order.2004 # Child returns to pick up the mantle
		100 = holy_order.2005 # A - Possibly Undesirable - Child Returns Home
		1000 = fp1_jomsvikings.0011	# FP1 - Jomsvikings terrorise their neighbours
		
		#Relationship Upgrade Events	
		75 = relation_upgrade.0001
		75 = relation_upgrade.1001
		75 = relation_upgrade.2001
		75 = relation_upgrade.2101
		
		#lunatic
		100 = trait_specific_ongoing.1001 # You're developing 'glass delusion'
		100 = trait_specific_ongoing.1003 # Collecting animals
		100 = trait_specific_ongoing.1005 # Talk to dead people
		100 = trait_specific_ongoing.1007 # A lunatic dreams of glass (enables the lunatic_building_decision decision)
		50 = trait_specific_ongoing.1008 # You kill a friend :(
		100 = trait_specific_ongoing.1009 # Grandiose delusions
		100 = trait_specific_ongoing.1010 # You love your warhorse
		100 = trait_specific_ongoing.1011 # Force your court to be naked
		20 = trait_specific_ongoing.1012 # Ravings
		100 = trait_specific_ongoing.1015 # Paranoid delusions
		#possessed
		100 = trait_specific_ongoing.2001 # Witchy or divine visions?
		100 = trait_specific_ongoing.2009 # Which god/saint is talking to me?
		100 = trait_specific_ongoing.2015 # Court physician wants to treat you
		100 = trait_specific_ongoing.2025 # Seizure surrounded by people
		#depressed
		100 = trait_specific_ongoing.3001 # You bond with a fellow depressed character
		100 = trait_specific_ongoing.3002 # Your court physician tries to treat you
		100 = trait_specific_ongoing.3009 # You're exhausted
		100 = trait_specific_ongoing.3015 # Someone calls you lazy
		#cannibal
		100 = trait_specific_ongoing.5001 # Private conversation with a vassal or courtier
		100 = trait_specific_ongoing.5003 # Eat someone from the staff
		100 = trait_specific_ongoing.5004 # Eat an old lady
		100 = trait_specific_ongoing.5005 # Eat a courtier
		#deviant
		100 = trait_specific_ongoing.6001 # Convert a lover to the freaky side of things
		100 = trait_specific_ongoing.6002 # You walk in on your deviant liege
		#drunkard
		#100 = trait_specific_ongoing.7001
		#incestuous
		#100 = trait_specific_ongoing.8001
		#Witch
		100 = witch.4000 #Annoying clergy
		100 = witch.4010 #Personal witch ritual
		100 = witch.4020 #Pray with potential friends
		25 = witch.4030  #Rare book
		
		# Friend Events
		10 = friendship.0003 #Friend might become Lover
		100 = friendship.1001 #Send Friend a gift
		500 = friendship.1006 # Receive wartime support from Friend
		100 = friendship.1008 #Send a good courtier to your Friend
		100 = friendship.2001 #Confess a secret to your Friend
		30 = friendship.2004 #Confess a Major secret to your Friend
		100 = friendship.2007 #Try to improve a character's impression of your Friend
		25 = friendship.3001 #Get along with your spouse's friend
		25 = friendship.3003 #You hate your spouse's friend
		100 = friendship.3006 #A Friend gets you a favor hook on one of your Councillors
		300 = friendship.3007 # Hanging out with your Friend reduces Stress
		
		# Rival Events	
		200 = rivalry.2001 #Hinder the progress of rival's Befriend scheme
		100 = rivalry.1001 #Rival adds stress
		100 = rivalry.1010 #Spiteful Acts ( my rival's aggravating behavior has gone on long enough)
		100 = rivalry.1030 #Meddling in Marriage
		100 = rivalry.3001 #Rival insults you
		100 = rivalry.3002 #You like the Rival of a Friend less
		100 = rivalry.3004 #Decrease opinion of rival because of opposing personality trait
		
		# Vassal Events
		100 = vassal.1001 # Religious liege wants you to build temple
		100 = vassal.1101 # Religious vassal wants you to build temple
		100 = vassal.2001 # Vassal wants liege to educate their child
		100 = vassal.2101 # No feast in a while, vassal requests it
		200 = vassal.2201 # You lend money from a vassal
		400 = vassal.2205 # Vassal reminds you of the money you owe them
		100 = vassal.2301 # Highly skilled vassal progresses development in province
		100 = vassal.2401 # Vassal wants gold, offers territory/better Vassal Contract
		100 = vassal.2451 # Vassal wants better contract, offers territory/gold
		100 = vassal.2501 # Peaceful vassal complains about ongoing war
		100 = vassal.2601 # Warmongering vassal complains about peace
		100 = vassal.2701 # Ask vassal to teach you CT
		100 = vassal.2801 # Liege complains abut no province improvement
		100 = vassal.2901 # Vassal requesting land they have claim on
		100 = vassal.3001 # You have no heir, ask a vassal for help
		100 = vassal.5010 # Zealous vassal wants liege to fight religious enemies
		100 = vassal.5050 # Vassal wants liege to fight war over his claim
		
		# Spouse Events
		75 = spouse.0001 #Increase opinion of spouse because of common personality
		75 = spouse.0003 #Increase opinion of spouse because of common lifestyle or education
		75 = spouse.0005 #Decrease opinion of spouse because of opposite personality
		75 = spouse.0007 #Increase opinion of spouse because of common friend
		75 = spouse.1001 #Increase opinion of an ambivalent spouse
		75 = spouse.1003 #Decrease opinion of an ambivalent spouse
		75 = spouse.2001 #Lose stress thanks to a loving spouse
		75 = spouse.2002 #An opportunity to speak highly of your spouse!
		75 = spouse.2012 #Share a secret with spouse
		75 = spouse.2014 #You suspect a plot against your spouse
		75 = spouse.3001 #Spouse adds stress
		75 = spouse.3002 #Spread rumours about your spouse
		75 = spouse.3012 #Pretend there is a plot against your spouse
		100 = intrigue_scheme_ongoing.5021 #Spouse/parent is plotting against someone!
		
		# Parent Events	
		75 = parent.1001 #Parent aids with Martial
		75 = parent.1002 #Parent aids with Diplomacy
		75 = parent.1003 #Parent aids with Intrigue
		75 = parent.1004 #Parent aids with Stewardship
		75 = parent.1005 #Parent aids with Learning
		50 = parent.1006 #Parent helps administrate one of your counties
		75 = parent.1007 #Parent helps with courtier opinion
		50 = parent.1009 #Parent gives you a new courtier
		75 = parent.1010 #Parent gives stress_loss
		
		# Secret Events	
		100 = secrets.1001 #Randomly learn a courtier's secrets
		100 = secrets.1002 #Courtier randomly learns one of court owner's minor secrets
		50 = secrets.1003 #Courtier randomly learns one of court owner's major secrets
		300 = secrets.1011 #A Friend discovers your secret lover
		100 = secrets.1100 #Discover a sibling's Bastard secret
		200 = secrets.2001 #A Just or Compassionate relation does not like your murder secret
		150 = secrets.3001 #A close relation disrupts a Scheme against you
		#Blackmail events
		100 = blackmail.1001 #Blackmailing a vassal causes Dread with the others
		100 = blackmail.1002 #Gain Stress from being under Blackmail
		
		# Lover Events
		50 = lover.1001 #A Lover shares someone's secret with you
		50 = lover.1002 #A Lover aids a diplomatic scheme
		100 = lover.3203 #Go to your spouse or your lover
		100 = lover.3206 #You're forced to wage war against your lover
		50 = lover.1003 #Lover helps you lose stress
		50 = lover.1004 #Travel somewhere with your lover
		200 = lover.1006 #Liege lover granting council position
		200 = lover.1007 #Liege lover granting better contract
		200 = lover.1008 #Liege lover granting county modifier
		100 = lover.2001 #Having a secret lover causes stress
		100 = lover.2002 #High stress damages your relationship to your Lover
		100 = lover.2004 #Question exclusive partner about spouse
		20 = lover.3002 #Start Love Letter chain
		50 = lover.0300 #Ask lover to be exclusive
		50 = lover.3201 #Leave lover_object_of_importance for lover to find
		100 = lover.3204 #Your lover is far far away
		100 = lover.3207 #Write letter to beloved!
		100 = lover.3211 # Send lover a painting
		100 = lover.3215 #Send a troubadour to lover's court
		100 = lover.3219 # Send a personal object to lover
		100 = lover.7001 #Chance that a good friend becomes a potential lover
		100 = lover.7003 #Chance that a rival becomes a potential lover
		50 = lover.7005 #Chance that a close family member becomes a potential lover
		
		#FP1 Events (These ones do not explicitly need you to be norse, but should be more likely if you are - present in both this and fp1_yearly_events)
		200 = fp1_yearly.2100 # Two lovers duel for your love
		200 = fp1_yearly.0521 # Blood on the Snow - your child wishes to snowball fight.
		200 = fp1_yearly.0531 # [Dynasty] on Ice - your child wants to learn how to ice skate.
		200 = fp1_yearly.0591 # Raised Voices at the Thing - two of your counties are fighting at a regional thing.
		200 = fp1_yearly.0601 # The Hardest Part of Ruling - you're incredibly bored in a protracted thing session.
		200 = fp1_yearly.0651 # Leviathan - you spot a whale whilst sailing.
		200 = fp1_yearly.0661 # A Novel Challenge - a knight challenges you to skiing.
		200 = fp1_yearly.0671 # A Slippery Slope - your child wants to go sledding.
		200 = fp1_yearly.0071 # In the Deep Places of the World - locals in your Scandi capital report a troll.
		15 = fp1_yearly.2000 # A Child wants to run away to marry their beloved
		
		#EP1 Flavor Events
		50 = ep1_flavor.0001 # A neighbouring court has a secret child
		100 = ep1_flavor.0011 # Diplomats from nearby realms have trashed your favourite hall.
		100 = ep1_flavor.0021 # You compete with another realm that shares your court language for grandeur.
		100 = ep1_flavor.0031 # Several fresh young scholars are newly arrived at court & need guidance.
		100 = ep1_flavor.1000 # A visiting eunuch offers their services
		100 = ep1_flavor.1200 # A learned eunuch wishes to sell various tips & tricks
		25 =  ep1_flavor.2000 # Invest in sports for your men-at-arms
		25 = ep1_flavor.2010 # Too many plots at court, which one is real?!
		25 = ep1_flavor.2020 # Two men-at-arms don't like each other
		25 = ep1_flavor.2030 # Rule on a dispute between two provincial characters
		100 = ep1_flavor.2041 # A trader offers an exotic weapon from a faraway land
		25 = ep1_flavor.2060 # Local merchant outed by local policeman
		25 = ep1_flavor.2070 # Interfere in a debate with a gifted visting scholar
		100 = language_events.0002 # Vassal who speak the language lauds your efforts
		
		#Flavor Events
		200 = yearly.9100 # Trouble in the Garden
		200 = yearly.9110 # The Flower Thief
		200 = yearly.9120 # The Seed Merchant

		#Artifact Modifiers
		50 = artifact.4000 # Cursed Rumors
		80 = artifact.4002 # A Dark Fame
		100 = artifact.4010 # A Killing Weapon of Fame
		100 = artifact.4020 # A Renowned Armor
		100 = artifact.4030 # The Crown of Our People
		80 = artifact.4040 # The Eye of the Expert
		100 = artifact.4050 # Anger Burst
		50 = artifact.4060 # The Blessed Sword of God
		100 = artifact.4070 # A Relic Desecrated
		100 = artifact.4080 # A Master Dueler's Weapon
		100 = artifact.4090 # A Relic and Weapon Combined

		#EP1 Courtly Events
		100 = court_yearly.1000 # Growing Debauchery
		100 = court_yearly.2001 # Competitive Cronying
		100 = court_yearly.6040 # Scrounger Life
		100 = court_yearly.1020 # Long Arm of the Law
		100 = court_yearly.5001 # Lonely Days
		100 = court_yearly.5010 # The Haunting
		100 = court_yearly.5020 # Pillow Talk
		100 = court_yearly.6030 # The Ballad of the Garlic King
		100 = court_yearly.7100 # Exotic Animal at Court
		100 = court_yearly.7200 # Loud and Proud
		100 = court_yearly.7030 # Foreign Merchants wish to establish a merchant quarter
		100 = court_yearly.7040 # Courtier on a pillar
		100 = court_yearly.4350 # Your caravans are attacked by rampaging Christian nobles!
		100 = court_yearly.4355 # one of our nobles attacked a trading caravan!
		100 = court_yearly.4800 # Spread Your Wings
		100 = court_yearly.0101 # Random Criminal Appears
		100 = court_yearly.0102 # Executioner feels lonely
		100 = court_yearly.0103 # Executioner selling items from prisoners
		100 = court_yearly.0104 # An Unhealthy Obsession
		100 = court_yearly.0106 # Dark Theatres for Dark Deeds
		100 = court_yearly.0110 # A Lecture on Lustfulness
		100 = court_yearly.8100 # Questionable Concoction
		100 = court_yearly.8120 # Novel Perspectives

		#Culture Events
		## Mendicant Mystics
		100 = culture_tradition_events.0101	# A mendicant mystic offers to teach your court's children for coin.
		100 = culture_tradition_events.0111	# A mendicant mystic seeks to teach you a lesson about HighGodName.
		100 = culture_tradition_events.0121	# A mendicant wishes to join your court.
		100 = culture_tradition_events.0131	# A mendicant is repulsed by your sins, and invokes the wrath of HighGodName against you.
		100 = culture_tradition_events.0141	# A mendicant of your culture, but not your faith, offers tutelage if you'll convert.

		#Trait Events
		100 = trait_specific.8501 # Someone mocks your lisp
		
		# FP2 - Fate of Iberia Events
		180 = fp2_yearly.2020	# Horchata colonialism event
		160 = fp2_yearly.8000	# Burning the Vineyards
		180 = fp2_yearly.8001	# Assembling the Cortes
		180 = fp2_yearly.8002	# A Dietary Dilemma 
		180 = fp2_yearly.8003	# Flight of Fancy
		180 = fp2_yearly.8004	# Translation School 
		180 = fp2_yearly.8005	# Under the Stone Pine 
		180 = fp2_yearly.8006	# Saqaliba Settlers 
		180 = fp2_struggle.1002	# Xenophilic Advancment
		160 = fp2_struggle.1050	# Dreams of Destruction
		150 = fp2_struggle.2000	# Disorderly Market
		140 = fp2_struggle.2008	# Misdeeds of the Councillor
		300 = fp2_struggle.2013	# The Secret to Freedom
		130 = fp2_struggle.2015	# Letter on the Back
		180 = fp2_yearly.2025	# Suffering from Success
		150 = fp2_yearly.4001	# You fancy a little siesta
		150 = fp2_yearly.4002	# A county is increasingly religiously intertwined
		150 = fp2_yearly.4003	# The road to Santiago is under threat from bandits
		150 = fp2_yearly.4007 	# Finding a shell on the road to Santiago
		150 = fp2_yearly.4008 	# Folk stories around the fireside
		300 = fp2_yearly.4009 	# Visiting the Malato Tree
		150 = fp2_yearly.4010 	# Finding a Verraco
		300 = fp2_yearly.3000 	# Neighboring Muslims are growing rice, adopt the practice yourself?
		150 = fp2_yearly.3001 	# Choosing your epitaph
		150 = fp2_yearly.3002 	# And They Were Roommates
		150 = fp2_yearly.3003 	# A Flavorful Evening
		180 = fp2_struggle.2003 # Band of Lost Birds

		#BP1 - Bontent Pack One Events
		100 = bp1_yearly.1000 # Best friend introduces you to a new hobby
		200 = bp1_yearly.1010 # A friend offers to mediate with your HoF who has excommunicated you
		500 = bp1_yearly.1020 # A friend visits you on your dying bed
		500 = bp1_yearly.1021 # You visit a friend on their dying bed
		500 = bp1_yearly.1030 # A rival visits you on your dying bed
		500 = bp1_yearly.1031 # You visit a rival on their dying bed
		100 = bp1_yearly.1040 # You make a new friend at the bathhouse
		50 = bp1_yearly.1050 # You make a new rival at the bathhouse
		100 = bp1_yearly.1060 # React to a superstitious friend
		150 = bp1_yearly.1061 # Make someone superstitious - hidden
		100 = bp1_yearly.1070 # Rival is superstitious - take advantage?
		100 = bp1_yearly.1080 # Married off relative writes home
		400 = bp1_yearly.1082 # Married off relative writes home to share a secret
		100 = bp1_yearly.2000 # Spoil your partner(s), learn a secret/hook followup
		400 = bp1_yearly.2010 # Two of your spouses/concubines are lovers!
		100 = bp1_yearly.2020 # A consort attempts to influence you into changing your heir
		100 = bp1_yearly.2030 # Mopey consort wants some guidance
		100 = bp1_yearly.2040 # Consort is upset with other consort
		100 = bp1_yearly.2050 # Friendly consorts wants to start a study circle
		200 = bp1_yearly.2060 # Friendly consorts want to tutor other consort's child
		100 = bp1_yearly.2070 # Childless older soulmate spouse ponders your relationship
		500 = bp1_yearly.3001 # Friend spots you some cash
		500 = bp1_yearly.3002 # You spot your friend some cash
		100 = bp1_yearly.3007 # Spouse's family member wants you to sponsor their inspiration
		100 = bp1_yearly.3100 # Your vassal/friend/family member offers you a skilled courtier
		20 = bp1_yearly.3101 # Friend offers to sell you a county you have a claim on
		100 = bp1_yearly.3201 #Fake feast invite from rival/nemesis
		100 = bp1_yearly.3300 # Remembering a pilgrimage 
		200 = bp1_yearly.3301 # Remembering a pilgrimage w/ a friend
		100 = bp1_yearly.4000 # Reflect over a family memory
		100 = bp1_yearly.4010 # Spouse demands their child gets a better guardian
		100 = bp1_yearly.4020 # Friend writes poetry about a war memory
		250 = bp1_yearly.4030 # Rival nestles their way into marrying one of your vassals, turns them disloyal
		10 = bp1_yearly.4040 # Kindly grandmother won't stop feeding you snacks; suffer the consequences of overeating, or break her heart?
		50 = bp1_yearly.5301 # Your friend is concerned about your physique
		150 = bp1_yearly.5100 # Chadsplaining to a plain courtier
		150 = bp1_yearly.5701 # Your Friend's Spouse Is Keeping Them Away From You
		100 = bp1_yearly.5702 # You ask a friend for help with skill
		200 = bp1_yearly.5703 # Your lover/rival threatens you in bed
		100 = bp1_yearly.5704 # Your rival seems strangely... attractive?
		200 = bp1_yearly.5705 # Your friend tries to talk you out of a bad relationship
		100 = bp1_yearly.5706 # You sleep with your rival's offspring
		400 = bp1_yearly.5707 # Your rival catches you sleeping with their offspring
		200 = bp1_yearly.5708 #You empathise with a friend's faith
		100 = bp1_yearly.5709 #Tempers flare between you and your rival
		100 = bp1_yearly.5713 #Your lover asks for money
		100 = bp1_yearly.5715 #You and a friend argue about pronunciation
		100 = bp1_yearly.5716 #Your zealous wife burns books
		100 = bp1_yearly.5717 #Your rival and your friend get into a drunken brawl
		100 = bp1_yearly.5719 #Your disloyal vassal is trying to embezzle
		100 = bp1_yearly.5720 #You and your rival armwrestle
		200 = bp1_yearly.5722 #Your nemesis launches your pet out of a catapult
		100 = bp1_yearly.5725 #You search for Khutulun
		100 = bp1_yearly.5728 #Rival steals and burns one of your artifacts
		10 = bp1_yearly.5740 #Scrambling for Answers
		80 = bp1_yearly.5800 #You make a perfume
		125 = bp1_yearly.6000 #Attacked by Rival's Child / Family Feud
		100 = bp1_yearly.7000 #Go on a picnic
		100 = bp1_yearly.7001 #Go fishing
		10 = bp1_yearly.7002 #Throw chamberpot at rival
		25 = bp1_yearly.7003 #Orgy Tapestry
		100 = bp1_yearly.7004 #Friend offers to talk about bad memory
		100 = bp1_yearly.7010 #Loyalty test
		100 = bp1_yearly.7050 #Memory of a war
		100 = bp1_yearly.7051 #Memory of Battle
		100 = bp1_yearly.7052 #Telling a story of a memory
		100 = bp1_yearly.7053 #A memory of revenge
		100 = bp1_yearly.7054 #Forgetting a memory
		100 = bp1_yearly.7055 #Recording a memory
		100 = bp1_yearly.7056 #Intimidating someone
		150 = bp1_yearly.7057 #Yearning
		100 = bp1_yearly.7058 #Friend eats all your food
		100 = bp1_yearly.8000 #Claimant moving towards rivalry
		200 = bp1_yearly.8010 #Best friend offers you a negotiated alliance
		100 = bp1_yearly.8020 #Rival of your rival offers friendship
		100 = bp1_yearly.8040 #Friend with conflicting personality falls out with you
		25 = bp1_yearly.8100 #Sycophant/favoritism chain start
		100 = bp1_yearly.9001 #Bully/guardian destroys your favourite toy
		100 = bp1_yearly.9005 #You get revenge for your destroyed toy
		100 = bp1_yearly.9006 #Becoming friends over a common sin
		10 = bp1_yearly.9007 #You find a peasant who looks exactly like you
		50 = bp1_yearly.9016 #Uppity second-in-line wants the throne
		50 = bp1_yearly.9017 #Uppity child is insecure about culture
		200 = bp1_yearly.9018 #Illegitimate child feels excluded
		100 = bp1_yearly.9019 #Spouse proposes a gay threesome
		200 = bp1_yearly.9020 #Spouse wants to do something kinky
		100 = bp1_yearly.9021 #Rival spouse is good in the bedroom
		100 = bp1_yearly.9022 #Friend holds an intervention
		200 = bp1_yearly.9023 #You realise you don't speak the same language
		100 = bp1_yearly.9024 #A friend visits you while you're sick
		150 = bp1_yearly.9025 #You realise you hate your friend
		100 = bp1_yearly.9026 #You're haunted by an old friend who convinces you to make ammends before you die
		100 = bp1_yearly.9034 # You find a terrifying bog witch
		100 = bp1_yearly.9037 # You find a bog corpse
		100 = bp1_yearly.9040 # The ghost of your dead lover wants to have sex again
		100 = bp1_yearly.9042 # Your chaplain finds a dessert that looks like HealthGodName
		100 = bp1_yearly.9043 # Your chaplain admits to being a deviant and a cannibal who eats babies
		10 = bp1_yearly.9046 # Your child poops themselves during their baptism
		100 = bp1_yearly.9047 # Lover wants you to wear their hair
		100 = bp1_yearly.9048 # Nemesis wants to end your rivalry by wrestling
		100 = bp1_yearly.9050 # You and a friend share war stories
		20 = bp1_yearly.7100 # Excreta incident, gain Nemesis

		# Family Feud
		250 = bp1_house_feud.0001 # Consider starting feud against own rival's house
		250 = bp1_house_feud.0002 # Consider starting feud against house family member rivals
		250 = bp1_house_feud.0003 # Consider starting feud against house who killed close family
		250 = bp1_house_feud.0006 # Consider starting feud against house with competing claims
		250 = bp1_house_feud.0007 # Consider starting feud against house who imprisoned you a while
		250 = bp1_house_feud.0008 # Consider starting feud against house who imprisoned family a while
		250 = bp1_house_feud.0012 # Consider starting feud against house who cuckolded you

		# FP3 - Frontier Events
		250 = fp3_yearly.8000 # Ghazi Gone Bad
		250 = fp3_yearly.8001 # Frontier Fortress Benefactor
		250 = fp3_yearly.8002 # Faith at the Frontier
		350 = fp3_yearly.8003 # Exotic Espand
		350 = fp3_yearly.8004 # The Frontier Beckons
		350 = fp3_yearly.8009 # Caliphal Concerns
		250 = fp3_yearly.8010 # Abode of War
		250 = fp3_yearly.8014 # Secrets of the Teapot
		250 = fp3_yearly.8016 # Forgotten Stones & Hyrcanian Havoc
		500 = fp3_yearly.8018 # Heavenly Horses
		100 = fp3_yearly.8888 #A Grazing Grievance (start of the Nomads Story Cycle)

		# FP3 - Heritage Events
		250 = fp3_yearly.8019 # Refuge of Light
		250 = fp3_yearly.8020 # The Lady of the Land
		350 = fp3_yearly.8021 # An Acidic Accident
		500 = fp3_yearly.8024 # The Return to the Sky
		350 = fp3_yearly.8027 # Nine-Hundred Ninety Chapters of Gold
		250 = fp3_yearly.8033 # Frozen Delights
		550 = fp3_yearly.8034 # The Hephthalite Hoard
		250 = fp3_yearly.8035 # The Heart and the Creator
		250 = fp3_yearly.8036 # The City of the Mouthless
		500 = fp3_yearly.8037 # A Cure for Acedia (the Melancholia Chain)
		300 = fp3_scholarship.1000	# Request Indian mathematician courtiers
		200 = fp3_scholarship.8500
		200 = fp3_scholarship.8600

		#FP3 - Extra Yearly Events
		150 = fp3_yearly.8045 #The Mysterious Bundle (the Buzina Chain)
		500 = false_conversion.2000 # A Moment of Weakness
		
		# FP3 - Zoroastrian Events
		200 = fp3_yearly.8050 #The Fate of the Dead
		200 = fp3_yearly.8051 # The Purest Fire 

		# Guardianship Events
		200 = childhood.2400 # Ward approaches guardian with theological doubts

		# Hunt
		50 = hunt.2000 # Dog salesman
		50 = hunt.2001 # Falcon salesman

		# Pilgrimage / Hajj
		50 = pilgrimage.0500 # Promise your dying religious relative to go on a Pilgrimage
		50 = hajj.0500 # Promise your dying Hajjaj relative to go on the Hajj

		#BP2 - Bontent Pack Two Events
		50 = pet_rock.0001 #You find a neat-looking rock
		10 = destiny_child.0001 #Destiny Child Story Cycle

		100 = bp2_yearly_extra.0001 #My favorite councilor
		
		200 = bp2_yearly.0601 # Ruling Rightly - Regent tries to teach you about state.
		100 = bp2_yearly.0611 # PrimaryTitle's Second Capital - Far away regent never seems to visit.
		200 = bp2_yearly.0621 # AuntUncle RegentFirstName - Nearby regents visits often.
		200 = bp2_yearly.0631 # Courtier-regent turns you against a rival for the regency.
		100 = bp2_yearly.0641 # Regent offers special present in exchange for your agreement on some documents.
		100 = bp2_yearly.0651 # Regent makes time for your interests, be they play or poetry.
		200 = bp2_yearly.0661 # Regent quarrels with your family about access to you.
		
		100 = bp2_yearly.1000 # Parent/Guardian: Your child/ward walks in on you performing your stress trait
		100 = bp2_yearly.1005 # Child: You notice your parent/guardian performing a stress trait
		100 = bp2_yearly.1010 # Parent/Guardian: Your child gives you a hug
		100 = bp2_yearly.1015 # Parent/Guardian: Your child/ward found a pouch of gold while exploring
		100 = bp2_yearly.1020 # Parent/Guardian: Your child/ward has found a secret in court
		100 = bp2_yearly.1030 # Parent: Your child does not have the same educational orientation as you. Change?
		100 = bp2_yearly.1035 # Parent/Guardian: Your child/ward has a rock collection
		100 = bp2_yearly.1040 # Parent/Guardian: Your child/ward has a text about martial arts
		100 = bp2_yearly.1045 # Parent/Guardian: There is a brawl among some children

		100 = bp2_yearly.2000 # You (a kid) learn about your house founder and can gain one of their traits (or the opposite)
		100 = bp2_yearly.2001 # You (a kid) learn about an ancestor and can gain one of their traits (or the opposite)
		100 = bp2_yearly.2100 # Build something with another child 
		# The following are upweighted for non-ai characters because we don't want the ai to start getting these traits at an inordinate rate
		10 = bp2_yearly.2110 # Gain Humble or Arrogant 
		10 = bp2_yearly.2120 # Gain Temperate or Gluttonous
		10 = bp2_yearly.2130 # Gain Generous or Greedy
		10 = bp2_yearly.2140 # Gain Honest or Deceitful
		10 = bp2_yearly.2150 # Gain Loyal or Disloyal
		10 = bp2_yearly.2160 # Gain Compassionate or Sadistic

		100 = bp2_yearly.3000 # Child bored of lesson
		
		150 = bp2_yearly.5000 # You have a chance to imprison the young prince/ss
		300 = bp2_yearly.5009 # You promise?
		100 = bp2_yearly.5050 # You learn a language off a guest or courtier
		150 = bp2_yearly.5051 # Child interacts with baby sibling
		300 = bp2_yearly.5052 # Child spends time with their grandparent
		300 = bp2_yearly.5053 # Host's child gets jealous of ward
		300 = bp2_yearly.5054 # Hostage and child are becoming friends
		100 = bp2_yearly.6000 # a same-culture ward or hostage doesn't know how to behave like one of you
		100 = bp2_yearly.6010 # a ward or hostage is sad and wants their family to send monies
		100 = bp2_yearly.6020 # hostage might reveal a family secret to you
		100 = bp2_yearly.6130 # hostage and a family member are becoming friends
		100 = bp2_yearly.6140 # hostage and a family member are becoming rivals
		100 = bp2_yearly.6150 # hostage is reticent to keep taking their place next to you during court appearances
		100 = bp2_yearly.6160 # your kid and your hostage snuck out of the palace to see your capital
		150 = bp2_yearly.6170 # your family mad that you sent a hostage to an uncivilized court
		
		100 = bp2_yearly.7000 # Wet nurse has a disease and can pass it down to a child
		100 = bp2_yearly.7001 # Spouse is jealous about wet nurse
		100 = bp2_yearly.7002 # Court Chaplain informs You that your marraige is incestuous, due to you having same wet nurse as your spouse
		10 = bp2_yearly.7003 # Wet Nurse informs you about first words of your child 
		10 = bp2_yearly.7004 # Wet Nurse informs you about first steps of your child
		10 = bp2_yearly.7005 # Wet Nurse informs you about first fallen teeth of your child
		10 = bp2_yearly.7006 # Wet Nurse informs you about first independent dress up of your child
		500 = bp2_yearly.7029 # You, a tribal ruler after completing Rites of Passage, can enourage or not next child doing the rites
		500 = bp2_yearly.7014 # Child and Wet Nurse connect over same faith/culture

		100 = bp2_yearly.8000 # Your hostage learns your court language!
		100 = bp2_yearly.8010 # A kid makes fun of your stupid accent
		100 = bp2_yearly.8020 # Childhood event, play with toys :D
		400 = bp2_yearly.8071 # 8070 follow-up - higher weight because it requires specific childhood event
		100 = bp2_yearly.8100 # You develop feelings for another kid, is this a crush?
		400 = bp2_yearly.8110 # Sacred childbirth, people want to pamper you
		200 = bp2_yearly.8120 # Sacred childbirth, offer to take care of your pregnant spouse
		50 = pet_rock.0001 #You find a neat-looking rock
		10 = destiny_child.0001 #Destiny Child Story Cycle
		25 = bp2_yearly.2010 # Imaginary Friend Story Cycle Start

		100 = bp2_yearly_extra.0001 #My favorite councilor

		#FP3 - Clan Events
		250 = fp3_clan.8000 # Usury against Unity, by Ola Jentzsch 
		250 = fp3_clan.8001 # Clan Quarrel, by Ola Jentzsch
		250 = fp3_clan.8002 # Bonds of Faith, by Ola Jentzsch
		250 = fp3_clan.8003 # The Power of a Name, by Ola Jentzsch
		250 = fp3_clan.8004 # Bonds of Fear, by Ola Jentzsch
		250 = fp3_clan.8005 # A Proper Position, by Ola Jentzsch
 		250 = fp3_clan.8006 # Small Spies, by Ola Jentzsch
 		250 = fp3_clan.8008 # Bleeding them Dry, by Ola Jentzsch
		250 = fp3_clan.8009 # Popular with the People, by Ola Jentzsch
		250 = fp3_clan.8010 # Competent Qadis / More Magistrates, by Ola Jentzsch
		250 = fp3_clan.8011 # A Proper Paymaster, by Ola Jentzsch
		250 = fp3_clan.8012 # Auspicious Avarice, by Ola Jentzsch
		240 = fp3_clan.8013 # The Burden of Tax Farming, by Ola Jentzsch
		250 = fp3_clan.8015 # Scandalous Scion, by Ola Jentzsch
		250 = fp3_clan.8016 # Hammam Havoc, by Ola Jentzsch
		250 = fp3_clan.8017 # A Questionable Position, by Ola Jentzsch 
		175 = fp3_clan.3000 # Ravaged Tulips, by Hugo Cortell

		# FP3 - Eren Events
		250 = fp3_yearly.2000 # Daylight Censors
		250 = fp3_yearly.2001 # Public Intoxication
		100 = fp3_yearly.2011 # Maunds of Wheat no royal court
		250 = fp3_yearly.2020 # Set the Scale, Vassal Version
		250 = fp3_yearly.2021 # Set the Scale, Liege Version
		500 = fp3_yearly.2040 # Commander of the Faithful

		# EP3 - Byzantine Events
		500 = ep3_emperor_yearly.2010 # Courtiers grumble about you sending an imperial prince/princess to marry abroad among barbarians
		250 = ep3_emperor_yearly.2140 # Plunder imperial graves if in debt
		250 = ep3_emperor_yearly.2150 # Stylite saint: is he for real or just faking it?
		250 = ep3_emperor_yearly.2160 # Pressure from bordering nomads
		250 = ep3_emperor_yearly.2170 # Use or disband the tunnels from a low-control county?
		200 = ep3_emperor_yearly.2190 # Landowner (estate owner) has been hoarding grain
		250 = ep3_emperor_yearly.2200 # Governor can embezzle taxes
		250 = ep3_emperor_yearly.2210 # Landless vassal present a prophecy to increase succession score
		200 = ep3_emperor_yearly.2220 # Monks complain about roaming shepherds
		250 = ep3_emperor_yearly.2230 # Riots against foreign merchants
		250 = ep3_emperor_yearly.2240 # Annoying "scholar" keeps quoting the Classics out of place
		250 = ep3_emperor_yearly.2320 # HoF helps you change state faith
		250 = ep3_emperor_yearly.8000 # Shortage of people in imperial capital
		250 = ep3_emperor_yearly.8010 # Fake imperial letter of introduction
		250 = ep3_emperor_yearly.8020 # Selling purple rights
		25 = ep3_emperor_yearly.8030 # Porphyrios strikes back - rare
		150 = ep3_emperor_yearly.8040 # Embrace Iconoclasm
		250 = ep3_emperor_yearly.8050 # Northern raider ransom
		250 = ep3_emperor_yearly.8060 # Border governor defects

		# EP3 - Governor Events
		250 = ep3_governor_yearly.8010 # Governor wants to swap a favor with you
		250 = ep3_governor_yearly.8020 # Extort an estate in your province
		250 = ep3_governor_yearly.8030 # Estate brings unexpected local benefits
		250 = ep3_governor_yearly.8040 # Estate is taking too much of your time
		500 = ep3_governor_yearly.8050 # Offer liege help in war targeting your province
		250 = ep3_governor_yearly.8060 # Embezzle from provincial treasury
		50 = ep3_governor_yearly.8070 # Overwhelmed by provincial bureaucracy
		250 = ep3_governor_yearly.8080 # Local magistrate accused of corruption
		250 = ep3_governor_yearly.8090 # Family that governed your province is jealous
		250 = ep3_governor_yearly.8100 # Neighboring governor wants your province
		250 = ep3_governor_yearly.8110 # Two neighboring governors falling out
		250 = ep3_governor_yearly.8120 # Support disaster victims in your governorship
		250 = ep3_governor_yearly.8130 # Raise arbitrary taxes on your province
		250 = ep3_governor_yearly.8140 # Stand up to an estate in your province
		250 = ep3_governor_yearly.8150 # Response to rebels in your province 
		250 = ep3_governor_yearly.8160 # Minority access to governor bureaucracy
		250 = ep3_governor_yearly.8170 # Prepare defense against nearby raiders

		# EP3 - Laamp Events
		250 = ep3_laamps.0050 # Close family members wants to become an adventurer

		# EP3 - Powerfam events
		250 = ep3_powerful_families.8000
		250 = ep3_powerful_families.8010
		250 = ep3_powerful_families.8030
		250 = ep3_powerful_families.8040
		250 = ep3_powerful_families.8060
		250 = ep3_powerful_families.8070
		
		# EP3 - Landless Admin Events
		250 = ep3_landless_admin.1000 # This guy could be a cool councillor
		250 = ep3_landless_admin.1010 # You have upgraded your estate a bunch, locals are impressed
		250 = ep3_landless_admin.1020 # Upgrade a building in your estate
		250 = ep3_landless_admin.1030 # You get offered a hook on your liege
		250 = ep3_landless_admin.1040 # Lie about a rival candidate
		250 = ep3_landless_admin.1050 # There's something in your basement

		# EP3 - Eparch events
		500 = ep3_eparch_event.0001
		500 = ep3_eparch_event.0005
		500 = ep3_eparch_event.0010
		500 = ep3_eparch_event.0015
		500 = ep3_eparch_event.0020

		# MPO - Nomadic Rulers Events
		100 = nomad_events.0001 # Starts the Achmach Fanakiti event chain
		250 = mpo_nomad_events.1030 # You choose a sport for your son to tryhard
		200 = mpo_nomad_events.1020 # Your kin wants to break off from your tribe
		250 = court_astrologer_events.0002 # Your Astrologer suggest a better place to migrate to
		250 = nomad_events.0100 # Two vassals have a herd dispute
		250 = nomad_events.0120 # You take an evening ride with someone
		250 = nomad_events.0130 # A merchant offers you some herd
		150 = nomad_events.0140 # A foreign merchant passes by your capital and asks to stay
		250 = nomad_events.0150 # You share a drink with a courtier
		300 = nomad_events.0160 # Your spouse tells you they admire you
		300 = nomad_events.0170 # Your spouse is scared of your high dread
		250 = nomad_events.0180 # Random courtier laughs at your child low prowess
		250 = nomad_events.0190 # Reminisce of a past memory
		250 = nomad_events.0200 # Someone tells you of a dream they had
		250 = nomad_events.0220 # Spouse scolds you for your low Prowess
		250 = nomad_events.0230 # Spouse is feeling homesick
		250 = nomad_events.0240 # Neighbouring Nomad's herd shows up in your capital
		100 = nomad_events.0250 # Enthusiastic priest asks you to convert
		150 = nomad_events.0260 # Distant priest arrives at your court
		150 = mpo_nomad_events.1050 # A neighboring herder is salty at you
		300 = mpo_nomad_events.1060 # You trade with non-nomad neighbors
		100 = mpo_nomad_events.1070 #You wake up after having ridden off alone
		200 = mpo_nomad_events.1080 #Neighbor is intruding on your land hunting a criminal
		200 = mpo_nomad_events.1100 #You adapt your herds to the local terrain
		200 = mpo_nomad_events.1110 #Your capital is by a place you can fish
		250 = mpo_events_tova.0025 # You are invited to a knucklebone shooting game
		250 = mpo_events_tova.0030 # No astrologer? Someone comes to you with a vision
		250 = mpo_events_tova.0035 # Anda comes to you with marital concerns
		250 = mpo_events_tova.0045 # A Treasured Friend
		250 = nomad_events_oltner.0001 # Hunt sighting in your lands
		250 = nomad_events_oltner.0002 # Bird sighting in your lands
		250 = nomad_events_oltner.0003 # Dangerous Hunt sighting in your lands
		150 = nomad_events_oltner.0004 # Zud - Dangerous animals eat your herd
		250 = nomad_events_oltner.0005 # Good season! Animals aplenty.
		250 = nomad_events_oltner.0006 # You are offered a skilled Master of the Chase from a tributary
		250 = nomad_events_oltner.0007 # You are offered a falcon from a tributary
		50 = mpo_bb_events.0001 # blood brother comes by for a wrestling match
		100 = mpo_events_anna.0001 #Train Them Young - teach a child how to ride a horse
		250 = mpo_events_anna.0005 #Stories from the Past - choose a story to be told
		250 = mpo_events_anna.0010 #Whistle Like an Arrow - being taught how to whistle as a child
		250 = mpo_events_ariana.0001 # Nest Sighting
		50 = mpo_events_ariana.0010 # Your Heir wants to convert to a different faith
		250 = mpo_events_ariana.0020 # A spouse is suspicious of a councillor
		250 = mpo_events_ariana.0050 # A family member risks being branded
		150 = mpo_events_ariana.0060 # A child in your family spots an eagles nest with treasure
		250 = mpo_events_ariana.0080 # Someone tells you about a magical tree
	  	150 = pet_animal.3050 # Your rival has an eagle
		250 = mpo_events_ariana.0090 # Your child wants to be a herder
		250 = mpo_events_ariana.0100 # A non-martial gender family member is very skilled
		150 = mpo_events_ariana.0110 # Your court astrologer wants you to move your capital
		
		# MPO - Season Specific Events
		500 = mpo_nomads_season_events.0001 # Herders robbed during drought
		500 = mpo_nomads_season_events.0005 # A hungry neighbour asks for herd
		500 = mpo_nomads_season_events.0010 # A well-to-do neighbor offers herd
		500 = mpo_nomads_season_events.0015 # Two Kurultai members fight over food
		200 = nomad_events.0110 # A snow wolf attacks a child (weighted up during white zud/cold zud)
		500 = nomad_events.0210 # Spouse/Child is worried about low herd
		200 = mpo_nomad_events.1120 #It's winter. wolves are hungry for your herd (weighted up during white zud/cold zud)
		
		# MPO - Settled Rulers Events
		500 = mpo_flavor_events_settled.0010 # Horse Lord at your door


		# ACH - yearly councillor events
		25 = ach_yearly_events.1001
		25 = ach_yearly_events.1002
		25 = ach_yearly_events.1003
		25 = ach_yearly_events.1004
	}
}
